<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>Book管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(function() {		
		$("#inputForm").validate({
			rules: {
				/*bookname:{
					required:true
				}*/
			},
			messages:{
				bookname:{
					required:"请输入书名"
				},
				bookpage:{
					required:"请输入书页",
					digits:"只能输入数字"
				}
			},
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/book/">Book列表</a></li>
		<li class="active"><a href="${ctx}/book/form?id=${book.id}">Book${not empty book.id?'修改':'添加'}</a></li>
	</ul><br/>
	
	<form:form id="inputForm" modelAttribute="book" action="${ctx}/book/save" method="post" enctype="multipart/form-data" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">书名：</label>
			<div class="controls">
				<form:input path="bookname" htmlEscape="false" maxlength="32" class="input-xlarge" id="bookname" required="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">出版日期：</label>
			<div class="controls">
			<input id="beginDate" name="createtime" type="text"  maxlength="20" class="input-xlarge" dateISO="true" required="true" value="<fmt:formatDate value="${book.createtime}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});">
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">出版社：</label>
			<div class="controls">
				<form:input path="press" htmlEscape="false" maxlength="32" class="input-xlarge" id="press"  required="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">封面：</label>
			<div class="controls">
				<input type="file" name="file" htmlEscape="false" maxlength="32" class="input-xlarge" required="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">页数：</label>
			<div class="controls">
				<form:input path="bookpage" htmlEscape="false" maxlength="32" digits="true" class="input-xlarge " required="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">作者：</label>
			<div class="controls">
				<form:input path="author" htmlEscape="false" maxlength="32" class="input-xlarge " id="author" required="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">价格：</label>
			<div class="controls">
				<form:input path="money" htmlEscape="false" maxlength="32" class="input-xlarge " id="money" required="true" number="true"/>
			</div>
		</div>
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="window.location.href='${ctx}/book'"/>
		</div>
	</form:form>	
</body>
</html>